<?php

/*
info: 缓存函数库
date: 2011-12-16
*/

if (!defined('WEBINROOT'))
{
	header("HTTP/1.0 404 Not Found");
	exit();
}

if (defined('CACHE_FUNC'))
{
	return;
}
define('CACHE_FUNC', TRUE);

//获取站点设置
function cache_GetSetting($bolRefresh = FALSE)
{
	global $db, $webconfig, $webcache;
	$strSign = 'setting';
	$strFile = cache_GetCacheFile($strSign);
	if (!$bolRefresh && file_exists($strFile))
	{
		include_once $strFile;
	}
	else
	{
		$cacheData = array('setting' => array());
		global_ConnectDB();
		$query = $db->Query("SELECT * FROM {$webconfig['dbpre']}settings");
		while ($tempdata = $db->FetchArray($query))
		{
			$tempvalue = @unserialize($tempdata['value']);
			$cacheData['setting'][$tempdata['variable']] = ($tempvalue!==FALSE) ? $tempvalue : $tempdata['value'];
		}
		cache_Write($strSign, cache_GetCacheVars($cacheData));
		$webcache['setting'] = $cacheData['setting'];
	}
	return $webcache['setting'];
}

//获取站点公告
function cache_GetNotice(CategoryDataModel $category, $bolRefresh = FALSE) {
	global $db, $webconfig, $webcache;

	$strSign = '/cache/index/notice';
	$strFile = cache_GetCacheFile($strSign);
	if (!$bolRefresh && file_exists($strFile)) {
		include_once $strFile;
	} else {
		$cacheData = array('notice' => array());
		if (isset($webcache['setting']['notice_category_id']) && $webcache['setting']['notice_category_id']) {
			$noticeID = intval($webcache['setting']['notice_category_id']);
			global_ConnectDB();

			$noticeIDs = array();
			if ($noticesCategory = $category->getChildForLayer($noticeID)) {
				$noticeIDs = array_keys($noticesCategory);
			}

			if ($noticeIDs) {
				$query = $db->Query("SELECT * FROM {$webconfig['dbpre']}news WHERE news_category_id IN (" . $db->BuildInSql($noticeIDs) . ")");
				while ($tempdata = $db->FetchArray($query)) {
					$tempdata['category'] = $category->getItem($tempdata['news_category_id']);
					$cacheData['notice'][$tempdata['id']] = $tempdata;
				}
			}
			cache_Write($strSign, cache_GetCacheVars($cacheData));
		}
		$webcache['notice'] = $cacheData['notice'];
	}
	return $webcache['notice'];
}

//获取首页显示新闻
function cache_GetShowIndexNews(CategoryDataModel $newsCategoryDataModel, $bolRefresh = FALSE) {
	global $db, $webconfig, $webcache;

	$strSign = '/cache/index/showindex';
	$strFile = cache_GetCacheFile($strSign);
	if (!$bolRefresh && file_exists($strFile))
	{
		include_once $strFile;
	}
	else
	{
		$limit = isset($webcache['setting']['show_index_limit']) && $webcache['setting']['show_index_limit'] ? intval($webcache['setting']['show_index_limit']) : 8;

		$cacheData = array('showindex' => array());
		global_ConnectDB();
		$query = $db->Query("SELECT * FROM {$webconfig['dbpre']}news WHERE `index` = 1 ORDER BY weight DESC, id DESC LIMIT 0, " . $limit);
		while ($tempdata = $db->FetchArray($query)) {
			if ($category = $newsCategoryDataModel->getItem($tempdata['news_category_id'])) {
				$tempdata['catagory_name'] = $category['name'];
			} else {
				$tempdata['catagory_name'] = '';
			}
			
			$cacheData['showindex'][$tempdata['id']] = $tempdata;
		}
		cache_Write($strSign, cache_GetCacheVars($cacheData));
		$webcache['showindex'] = $cacheData['showindex'];
	}
	return $webcache['showindex'];
}

//获取热点新闻
function cache_GetHotNews(CategoryDataModel $newsCategoryDataModel, $bolRefresh = FALSE) {
	global $db, $webconfig, $webcache;
	$strSign = '/cache/index/hotnews';
	$strFile = cache_GetCacheFile($strSign);
	if (!$bolRefresh && file_exists($strFile))
	{
		include_once $strFile;
	}
	else
	{
		$limit = isset($webcache['setting']['hot_limit']) && $webcache['setting']['hot_limit'] ? intval($webcache['setting']['hot_limit']) : 10;

		$cacheData = array('hotnews' => array());
		global_ConnectDB();
		$query = $db->Query("SELECT * FROM {$webconfig['dbpre']}news WHERE `ishot` = 1 ORDER BY weight DESC, id DESC LIMIT 0, " . $limit);
		while ($tempdata = $db->FetchArray($query)) {
			if ($category = $newsCategoryDataModel->getItem($tempdata['news_category_id'])) {
				$tempdata['catagory_name'] = $category['name'];
			} else {
				$tempdata['catagory_name'] = '';
			}
			$cacheData['hotnews'][$tempdata['id']] = $tempdata;
		}
		cache_Write($strSign, cache_GetCacheVars($cacheData));
		$webcache['hotnews'] = $cacheData['hotnews'];
	}
	return $webcache['hotnews'];
}

//获取最新优惠劵
function cache_GetNewCoupon($bolRefresh = FALSE) {
	global $db, $webconfig, $webcache, $webserver, $webglobal;

	if ($bolRefresh) {
		$strSign = '/cache/newcoupon/newcoupon_temp';
		$strFile = cache_GetCacheFile($strSign);
		$strDirPath = dirname($strFile);
		ClearFolder($strDirPath);
		return true;
	}

	$strSign = '/cache/newcoupon/newcoupon_' . $webglobal['curcityid'];
	$strFile = cache_GetCacheFile($strSign);

	if (!$bolRefresh && file_exists($strFile))
	{
		include_once $strFile;
	}
	else
	{
		$sqlCondition = isset($webglobal['curcityid']) && $webglobal['curcityid'] ? ' AND C.city = '. $webglobal['curcityid'] : '';

		$cacheData = array(
			'newcoupon' => array(
				1 => array(),
				2 => array()
			)
		);
		$endTime = $webserver['timestamp'] - 259200;
		global_ConnectDB();
		$query = $db->Query("SELECT N.* FROM {$webconfig['dbpre']}coupon N LEFT JOIN {$webconfig['dbpre']}company C ON N.company_id = C.id WHERE N.`status` = 1 AND N.starttime <={$webserver['timestamp']} AND N.endtime >= {$endTime} AND C.status = 1{$sqlCondition} ORDER BY N.pubtime DESC, id DESC LIMIT 0, 6");

		$num = 0;
		while ($tempdata = $db->FetchArray($query)) {
			if ($tempdata['image']) {
				$tempdata['thumbnail'] = array(
					'big' => getThumbnails($tempdata['image'], 'big'),
					'small' => getThumbnails($tempdata['image'], 'small'),
					'middle' => getThumbnails($tempdata['image'], 'middle')
				);
			}

			$num++;
			$offsetkey = ceil($num / 3);
			$cacheData['newcoupon'][$offsetkey][$tempdata['id']] = $tempdata;

		}
		cache_Write($strSign, cache_GetCacheVars($cacheData));
		$webcache['newcoupon'] = $cacheData['newcoupon'];
	}
	return $webcache['newcoupon'];
}

//获取热门优惠劵
function cache_GetHotCoupon($bolRefresh = FALSE) {
	global $db, $webconfig, $webcache, $webserver, $webglobal;

	if ($bolRefresh) {
		$strSign = '/cache/hotcoupon/hotcoupon_temp';
		$strFile = cache_GetCacheFile($strSign);
		$strDirPath = dirname($strFile);
		ClearFolder($strDirPath);
		return true;
	}

	$cacheLifeTime = 900; //15 minutes

	$limit = isset($webcache['setting']['hot_coupon_limit']) && $webcache['setting']['hot_coupon_limit'] ? intval($webcache['setting']['hot_coupon_limit']) : 7;

	$strSign = '/cache/hotcoupon/hotcoupon_' . $webglobal['curcityid'];
	$strFile = cache_GetCacheFile($strSign);

	if (CheckCacheExpire($strFile, $cacheLifeTime)) {

		include_once $strFile;

	} else {

		$cacheData = array(
			'hotcoupon' => array(
				'day'        => array(),
				'week'       => array(),
				'month'       => array(),
			)
		);

		$sqlCondition = isset($webglobal['curcityid']) && $webglobal['curcityid'] ? ' AND p.city = '. $webglobal['curcityid'] : '';

		global_ConnectDB();
		
		$currentTime = global_FormatTime($webserver['timestamp'], 'FD');
		list($year, $month, $day) = explode('-', $currentTime);

		$couponID = array();

		//按天分组
		$query = $db->Query("SELECT c.* 
							FROM {$webconfig['dbpre']}coupon_views v LEFT JOIN {$webconfig['dbpre']}coupon c ON v.coupon_id = c.id
							LEFT JOIN {$webconfig['dbpre']}company p ON c.company_id = p.id 
							WHERE v.year = '{$year}' AND v.month = '{$month}' AND v.day = '{$day}' AND c.status = 1 AND p.status = 1{$sqlCondition}
							ORDER BY v.views DESC LIMIT 0, " . $limit);

		while ($tempdata = $db->FetchArray($query)) {
			$tempdata['discount'] = $tempdata['original'] > 0 ? number_format(($tempdata['price'] / $tempdata['original']) * 10, 1) : 0;
			$tempdata['discount_num'] = number_format(($tempdata['original'] - $tempdata['price']), 1);
			if ($tempdata['image']) {
				$tempdata['thumbnail'] = array(
					'big' => getThumbnails($tempdata['image'], 'big'),
					'small' => getThumbnails($tempdata['image'], 'small'),
					'middle' => getThumbnails($tempdata['image'], 'middle')
				);
			}
			$cacheData['hotcoupon']['day'][$tempdata['id']] = $tempdata;
			//$couponID[] = $tempdata['coupon_id'];
		}

		//按周分组
		$strSql = "SELECT c.*, SUM(v.views) AS totalviews 
					FROM {$webconfig['dbpre']}coupon_views v LEFT JOIN {$webconfig['dbpre']}coupon c ON v.coupon_id = c.id
					LEFT JOIN {$webconfig['dbpre']}company p ON c.company_id = p.id 
					WHERE %s AND c.status = 1 AND p.status = 1{$sqlCondition}
					GROUP BY v.coupon_id ORDER BY totalviews DESC, v.coupon_id DESC LIMIT 0, " . $limit;

		
		$currentWeekNum = global_FormatTime($webserver['timestamp'], 'N');
		$startWeekTime = global_ConvTime($currentTime . '00:00:00') - (($currentWeekNum - 1) * 86400);
		$query = $db->Query(sprintf($strSql, 'v.addtime >=' . $startWeekTime));

		while ($tempdata = $db->FetchArray($query)) {
			$tempdata['discount'] = $tempdata['original'] > 0 ? number_format(($tempdata['price'] / $tempdata['original']) * 10, 1) : 0;
			$tempdata['discount_num'] = number_format(($tempdata['original'] - $tempdata['price']), 1);
			if ($tempdata['image']) {
				$tempdata['thumbnail'] = array(
					'big' => getThumbnails($tempdata['image'], 'big'),
					'small' => getThumbnails($tempdata['image'], 'small'),
					'middle' => getThumbnails($tempdata['image'], 'middle')
				);
			}

			$cacheData['hotcoupon']['week'][$tempdata['id']] = $tempdata;
			//$couponID[] = $tempdata['coupon_id'];
		}

		//按月分组
		$startMonthTime = global_ConvTime($year.'-'.$month.'-1 00:00:00');
		$query = $db->Query(sprintf($strSql, 'v.addtime >=' . $startMonthTime));
		while ($tempdata = $db->FetchArray($query)) {
			$tempdata['discount'] = $tempdata['original'] > 0 ? number_format(($tempdata['price'] / $tempdata['original']) * 10, 1) : 0;
			$tempdata['discount_num'] = number_format(($tempdata['original'] - $tempdata['price']), 1);
			if ($tempdata['image']) {
				$tempdata['thumbnail'] = array(
					'big' => getThumbnails($tempdata['image'], 'big'),
					'small' => getThumbnails($tempdata['image'], 'small'),
					'middle' => getThumbnails($tempdata['image'], 'middle')
				);
			}
			$cacheData['hotcoupon']['month'][$tempdata['id']] = $tempdata;
			//$couponID[] = $tempdata['coupon_id'];
		}

		//如果当天没有人点击优惠劵,将查询默认优惠劵(按收藏次数倒序)

		$endTime = $webserver['timestamp'] - 259200;
		if (empty($cacheData['hotcoupon']['day'])) {
			$query = $db->Query("SELECT * 
							FROM {$webconfig['dbpre']}coupon WHERE starttime <={$webserver['timestamp']} AND endtime >= {$endTime} AND status = 1
							ORDER BY favorites_num DESC,id DESC LIMIT 0, " . $limit);
			while ($tempdata = $db->FetchArray($query)) {
				$tempdata['discount'] = $tempdata['original'] > 0 ? number_format(($tempdata['price'] / $tempdata['original']) * 10, 1) : 0;
				$tempdata['discount_num'] = number_format(($tempdata['original'] - $tempdata['price']), 1);
				if ($tempdata['image']) {
					$tempdata['thumbnail'] = array(
						'big' => getThumbnails($tempdata['image'], 'big'),
						'small' => getThumbnails($tempdata['image'], 'small'),
						'middle' => getThumbnails($tempdata['image'], 'middle')
					);
				}
				$cacheData['hotcoupon']['day'][$tempdata['id']] = $tempdata;
				$cacheData['hotcoupon']['week'][$tempdata['id']] = $tempdata;
				$cacheData['hotcoupon']['month'][$tempdata['id']] = $tempdata;
				//$couponID[] = $tempdata['coupon_id'];
			}
		}

		cache_Write($strSign, cache_GetCacheVars($cacheData));
		$webcache['hotcoupon'] = $cacheData['hotcoupon'];
	}
	return $webcache['hotcoupon'];
}

//获取优惠劵详情
function cache_GetCouponDetail($id, $bolRefresh = FALSE, $onlyDelete = false) {
    
	global $db, $webconfig, $webserver;
    
    $cacheKey = 'coupon_'.$id;
    /*
	$fileNum = ceil($id / 2000);
	$strSign = '/cache/coupon/coupon_'.$fileNum.'/coupon_' . $id;
	$strFile = cache_GetCacheFile($strSign);

	$cacheKey = 'coupon_'.$id;

	if ($onlyDelete) {
		@unlink($strFile);
		return;
	}

	if (!$bolRefresh && file_exists($strFile)) {
		include_once $strFile;
	} else {
		$cacheData = array(
			$cacheKey => array(
				'coupon'      => array(),
				'company'     => array(),
				'othercoupon' => array()
			)
		);
    */
		global_ConnectDB();

		if ($couponData = $db->GetOne("SELECT * FROM {$webconfig['dbpre']}coupon WHERE id={$id}")) {
			$couponData['starttime_show'] = !empty($couponData['starttime']) ? global_FormatTime($couponData['starttime'], 'Y年n月j日') : '';
			$couponData['endtime_show'] = !empty($couponData['endtime']) ? global_FormatTime($couponData['endtime'], 'Y年n月j日') : '';
			$couponData['pubtime_show'] = !empty($couponData['pubtime']) ? global_FormatTime($couponData['pubtime']) : '';
			$couponData['isabled'] = $couponData['starttime'] <= $webserver['timestamp'] && $couponData['starttime'] >= $couponData['endtime'] ? true : false;

			if ($couponData['image']) {
				$couponData['thumbnail'] = array(
					'big' => getThumbnails($couponData['image'], 'big'),
					'small' => getThumbnails($couponData['image'], 'small'),
					'middle' => getThumbnails($couponData['image'], 'middle')
				);
			}

			$cacheData[$cacheKey]['coupon'] = $couponData;
			$cacheData[$cacheKey]['company'] = array();
			$cacheData[$cacheKey]['othercoupon'] = array();
			//查询对应的商家
			if ($companyData = $db->GetOne("SELECT * FROM {$webconfig['dbpre']}company WHERE id={$couponData['company_id']} AND status=1")) {
				$cacheData[$cacheKey]['company'] = $companyData;

				$endTime = $webserver['timestamp'] - 259200;
				//查询商家发布的优惠劵
				$query = $db->Query("SELECT * FROM {$webconfig['dbpre']}coupon WHERE id != {$id} AND company_id = '{$couponData['company_id']}' AND endtime >= {$endTime} AND status = 1");
				while ($tempdata = $db->FetchArray($query)) {
					$tempdata['discount'] = $tempdata['original'] > 0 ? number_format(($tempdata['price'] / $tempdata['original']) * 10, 1) : 0;
					$tempdata['discount_num'] = number_format(($tempdata['original'] - $tempdata['price']), 1);
					if ($tempdata['image']) {
						$tempdata['thumbnail'] = array(
							'big' => getThumbnails($tempdata['image'], 'big'),
							'small' => getThumbnails($tempdata['image'], 'small'),
							'middle' => getThumbnails($tempdata['image'], 'middle')
						);
					}
					$cacheData[$cacheKey]['othercoupon'][$tempdata['id']] = $tempdata;
				}
			}
		//}

		//cache_Write($strSign, cache_GetCacheVars($cacheData));
		$webcache[$cacheKey] = $cacheData[$cacheKey];
	}

	return $webcache[$cacheKey];
}

function cache_GetNewCompany($bolRefresh = FALSE, $onlyDelete = false) {
	global $db, $webconfig, $webcache, $webserver, $webglobal;

	if ($onlyDelete) {
		$strSign = '/cache/newcompany/newcompany_temp';
		$strFile = cache_GetCacheFile($strSign);
		$strDirPath = dirname($strFile);
		
		ClearFolder($strDirPath);
		return true;
	}

	$strSign = '/cache/newcompany/newcompany_' . $webglobal['curcityid'];
	$strFile = cache_GetCacheFile($strSign);

	if (!$bolRefresh && file_exists($strFile)) {
		include_once $strFile;
	}
	else
	{
		$sqlCondition = isset($webglobal['curcityid']) && $webglobal['curcityid'] ? ' AND city = '. $webglobal['curcityid'] : '';

		$cacheData = array('newcompany' => array());
		global_ConnectDB();
		$query = $db->Query("SELECT * FROM {$webconfig['dbpre']}company WHERE `status` = 1{$sqlCondition} ORDER BY addtime DESC, id DESC LIMIT 0, 4");

		while ($tempdata = $db->FetchArray($query)) {
			if ($tempdata['logo'] != '') {
				$tempdata['logo_thumbnail'] = array(
					'small' => getThumbnails($tempdata['logo'], 'small'),
				);
			}

			$cacheData['newcompany'][$tempdata['id']] = $tempdata;
		}

		cache_Write($strSign, cache_GetCacheVars($cacheData));
		$webcache['newcompany'] = $cacheData['newcompany'];
	}
	return $webcache['newcompany'];
}

function cache_GetCompanyDetail($id, $bolRefresh = FALSE, $onlyDelete = false) {
	global $db, $webconfig;

	$fileNum = ceil($id / 2000);
	$strSign = '/cache/company/company_'.$fileNum.'/company_' . $id;
	$strFile = cache_GetCacheFile($strSign);

	$cacheKey = 'company_'.$id;

	if ($onlyDelete) {
		@unlink($strFile);
		return;
	}

	if (!$bolRefresh && file_exists($strFile)) {

		include_once $strFile;

	} else {
		$cacheData = array(
			$cacheKey => array(
				'company' => array(),
				'coupon'  => array()
			)
		);

		global_ConnectDB();

		if ($companyData = $db->GetOne("SELECT * FROM {$webconfig['dbpre']}company WHERE id={$id} AND status=1")) {
			$cacheData[$cacheKey]['company'] = $companyData;
		}

		//获取该商家发布的优惠劵
		
		cache_Write($strSign, cache_GetCacheVars($cacheData));
		$webcache[$cacheKey] = $cacheData[$cacheKey];
	}

	return $webcache[$cacheKey];
}


function ClearFolder($strFolder, $intMode = 0) {
	if (substr($strFolder, -1) == '/')
	{
		$strFolder = substr($strFolder, 0, -1);
	}
	if (is_dir($strFolder))
	{
		$tempCurFolder = @opendir($strFolder);
		while ($tempEntryName = @readdir($tempCurFolder))
		{
			if ($tempEntryName!='.' && $tempEntryName!='..')
			{
				$tempFullPath = $strFolder.'/'.$tempEntryName;
				if (!is_dir($tempFullPath))
				{
					@unlink($tempFullPath);
				}
				else
				{
					$tempUnderMode = ($intMode == 2) ? 2 : 0;
					ClearFolder($tempFullPath, $tempUnderMode);
				}
			}
		}
		@closedir($tempCurFolder);
		if ($intMode == 0)
		{
			@rmdir($strFolder);
		}
	}
}

//判断缓存文件是否过期
function CheckCacheExpire($strFile, $strTimeSet = 0) {
	global $webserver;
	if (file_exists($strFile)) {
		if ($strTimeSet > 0) {
			$tempNextTime = filemtime($strFile) + $strTimeSet;
			if ($tempNextTime < $webserver['timestamp']) {
				return false;
			}
		}
		return true;
	}
	return FALSE;
}

//获取缓存文件
//$intStripPath 是否去掉绝对地址前部
function cache_GetCacheFile($strFile, $intStripPath = 1)
{
	if ($intStripPath==1)
	{
		$strFile = preg_replace("/^".preg_quote(WEBFILEPATH, '/')."/", "", $strFile);
	}
	$filepath = dirname($strFile);
	$filename = basename($strFile);
	if ($filepath=='' || $filepath=='.')
	{
		$filepath = WEBFILEPATH.'/cache/system';
	}
	elseif ($filepath=='/' || $filepath=='\\')
	{
		$filepath = WEBFILEPATH;
	}
	elseif (substr($filepath, 0, 1)=='/')
	{
		$filepath = WEBFILEPATH.$filepath;
	}
	else
	{
		$filepath = WEBFILEPATH.'/cache/system/'.$filepath;
	}
	if (global_FileExt($filename)=='')
	{
		$filename = 'cache_'.$filename.'.php';
	}
	return "{$filepath}/{$filename}";
}

//转换为变量
function cache_GetCacheVars($data, $type = 'VAR')
{
	$evaluate = '';
	foreach ($data as $key => $val)
	{
		if (is_array($val))
		{
			$evaluate .= "\$webcache['$key'] = ".cache_GetCacheVarsFormat($val).";\n\n";
		}
		else
		{
			$val = addcslashes($val, '\'\\');
			$evaluate .= $type == 'VAR' ? "\$webcache['$key'] = '$val';\n" : "define('".strtoupper($key)."', '$val');\n";
		}
	}
	return $evaluate;
}

//数组显示格式化
function cache_GetCacheVarsFormat($array, $level = 0)
{
	$space = '';
	for ($i=0; $i<=$level; $i++)
	{
		$space .= "\t";
	}
	$evaluate = "array\n$space(\n";
	$comma = $space;
	foreach ($array as $key => $val)
	{
		$key = is_string($key) ? '\''.addcslashes($key, '\'\\').'\'' : $key;
		$val = !is_array($val) ? '\''.addcslashes($val, '\'\\').'\'' : $val;
		if (is_array($val))
		{
			$evaluate .= "$comma$key => ".cache_GetCacheVarsFormat($val, $level+1);
		}
		else
		{
			$evaluate .= "$comma$key => $val";
		}
		$comma = ",\n$space";
	}
	$evaluate .= "\n$space)";
	return $evaluate;
}

/**
 * 写入缓存文件
 * @param $strFile 缓存文件
 * @param $strCacheData 缓存数据
 * @param $bolPhpCode 是否是PHP格式
 * @param $bolAdd 是否在原文件末尾追加内容
 * @param $bolStop 是否错误后立即停止
 * @return bool 或者 直接停止显示错误
 */
function cache_Write($strFile, $strCacheData, $bolPhpCode = TRUE, $bolAdd = FALSE, $bolStop = TRUE)
{
	if ($strFile != '')
	{
		$strFile = cache_GetCacheFile($strFile);
		$tempOpenMode = ($bolAdd) ? 'ab' : 'wb';
		if (global_CreateFolder(dirname($strFile)) && @$fp=fopen($strFile, $tempOpenMode))
		{
			flock($fp, LOCK_EX);
			if ($bolPhpCode)
			{
				fwrite($fp, "<?php\n\n!defined('WEBINROOT') and exit();\n\n{$strCacheData}\n?>");
			}
			else
			{
				fwrite($fp, $strCacheData);
			}
			flock($fp, LOCK_UN);
			fclose($fp);
			@chmod($strFile, 0777);
			return TRUE;
		}
		elseif ($bolStop)
		{
			exit('Can not write cache file: '.basename($strFile).'.');
		}
	}
	return FALSE;
}
